package search;

/**
 * 暴力查找
 */
public class SeqSearch {
    public static void main(String[] args) {
        int arr[] = {1,9,11,-1,34,89};
        int index = seqSearch(arr,11);
        if (index==-1){
            System.out.println("没有找到");
        }else {
            System.out.println(index);
        }
    }

    /**
     * 这里的线性查找是找第一个返回下标
     */
    private static int seqSearch(int[]arr,int value){
        for (int i = 0; i < arr.length; i++) {
            if (value==arr[i]){
                return i+1;
            }
        }
        return -1;
    }
}
